package com.firefoxking.mysite.service.meta.impl;

import com.firefoxking.mysite.dao.MetadataMapper;
import com.firefoxking.mysite.dao.dto.MetaCond;
import com.firefoxking.mysite.entity.Metadata;
import com.firefoxking.mysite.service.meta.MetadataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MetadataServiceImpl implements MetadataService {

    @Autowired
    private MetadataMapper metadataMapper;

    @Override
    public int addMetadata(Metadata metadata) {
        // 没有统一异常处理
        if (null == metadata)
            throw new RuntimeException();
        return metadataMapper.addMetadata(metadata);
    }

    @Override
    public int deleteMetadataById(Integer mid) {
        return metadataMapper.deleteMetadataById(mid);
    }

    @Override
    public int updateMetadataById(Metadata metadata) {
        return metadataMapper.updateMetadataById(metadata);
    }

    @Override
    public Metadata getMetadataById(Integer mid) {
        return metadataMapper.getMetadataById(mid);
    }

    @Override
    public List<Metadata> getMetadataByCond(MetaCond metaCond) {
        return metadataMapper.getMetadataByCond(metaCond);
    }
}
